﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdLyLayerFilter : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdLyLayerFilter(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdLyLayerFilter_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdLyLayerFilter obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdLyLayerFilter()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdLyLayerFilter(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdLyLayerFilter cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdLyLayerFilter_cast(OdRxObject.getCPtr(pObj));
			OdLyLayerFilter result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdLyLayerFilter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdLyLayerFilter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdLyLayerFilter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdLyLayerFilter_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdLyLayerFilter_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdLyLayerFilter_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdLyLayerFilter createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdLyLayerFilter_createObject();
			OdLyLayerFilter result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdLyLayerFilter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdLyLayerFilter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdLyLayerFilter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual string name()
		{
			string result = TD_DbPINVOKE.OdLyLayerFilter_name(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool setName(string name)
		{
			bool result = TD_DbPINVOKE.OdLyLayerFilter_setName(this.swigCPtr, name);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool allowRename()
		{
			bool result = TD_DbPINVOKE.OdLyLayerFilter_allowRename(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdLyLayerFilter parent()
		{
			OdLyLayerFilter result = (OdLyLayerFilter)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdLyLayerFilter_parent(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdLyLayerFilterArray getNestedFilters()
		{
			OdLyLayerFilterArray result = new OdLyLayerFilterArray(TD_DbPINVOKE.OdLyLayerFilter_getNestedFilters(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void addNested(OdLyLayerFilter pLayerFilter)
		{
			TD_DbPINVOKE.OdLyLayerFilter_addNested(this.swigCPtr, OdLyLayerFilter.getCPtr(pLayerFilter));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void removeNested(OdLyLayerFilter pLayerFilter)
		{
			TD_DbPINVOKE.OdLyLayerFilter_removeNested(this.swigCPtr, OdLyLayerFilter.getCPtr(pLayerFilter));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdResult generateNested()
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdLyLayerFilter_generateNested(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool dynamicallyGenerated()
		{
			bool result = TD_DbPINVOKE.OdLyLayerFilter_dynamicallyGenerated(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool allowNested()
		{
			bool result = TD_DbPINVOKE.OdLyLayerFilter_allowNested(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool allowDelete()
		{
			bool result = TD_DbPINVOKE.OdLyLayerFilter_allowDelete(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isProxy()
		{
			bool result = TD_DbPINVOKE.OdLyLayerFilter_isProxy(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isIdFilter()
		{
			bool result = TD_DbPINVOKE.OdLyLayerFilter_isIdFilter(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool filter(OdDbLayerTableRecord layer)
		{
			bool result = TD_DbPINVOKE.OdLyLayerFilter_filter(this.swigCPtr, OdDbLayerTableRecord.getCPtr(layer));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual string filterExpression()
		{
			string result = TD_DbPINVOKE.OdLyLayerFilter_filterExpression(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdLyBoolExpr filterExpressionTree()
		{
			IntPtr intPtr = TD_DbPINVOKE.OdLyLayerFilter_filterExpressionTree(this.swigCPtr);
			OdLyBoolExpr result = (intPtr == IntPtr.Zero) ? null : new OdLyBoolExpr(intPtr, false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult setFilterExpression(string filterExpression)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdLyLayerFilter_setFilterExpression(this.swigCPtr, filterExpression);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool compareTo(OdLyLayerFilter pOther)
		{
			bool result = TD_DbPINVOKE.OdLyLayerFilter_compareTo(this.swigCPtr, OdLyLayerFilter.getCPtr(pOther));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult readFrom(OdDbDxfFiler pFiler)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdLyLayerFilter_readFrom(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void writeTo(OdDbDxfFiler pFiler)
		{
			TD_DbPINVOKE.OdLyLayerFilter_writeTo(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
